package com.smashcrush.server.rest;

import java.util.Map;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.smashcrush.model.Script;
import com.smashcrush.model.ScriptResults;
import com.smashcrush.server.service.TestingService;

@Controller
@Path("/api/testing")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class TestingResource {

	@Autowired
	TestingService testingService;

	@POST
	@Path("token/{token}/poll/script")
	public Script pollScript(@PathParam("token") String token) {
		return testingService.pollScript(token);
	}

	@POST
	@Path("token/{token}/poll/results")
	public ScriptResults pollResults(@PathParam("token") String token) {
		return testingService.pollResults(token);
	}

	@POST
	@Path("token/{token}/push/script")
	public void pushScript(@PathParam("token") String token, Script script) {
		testingService.pushScript(token, script);
	}

	@POST
	@Path("token/{token}/push/results")
	public void pushResults(@PathParam("token") String token,
			Map<String, String> results) {
		testingService.pushResults(token, results);
	}

}